/**
 * Created by gemini on 2017/4/24.
 */
myApp.controller('gatelistCtrl',function ($scope,$cookieStore,gateService) {
    $cookieStore.company_id =  $cookieStore.get("operator").company_id;

    $scope.pages = {
        maxSize:10,
        pageSize:10,
        currentPage:1,
        totalPages:""
    };


    var commonList = function (company_id,pages,size) {
        gateService.gateList(company_id,pages,size,function (data) {
            if(!data.errno == 0){
                alert(data.errmsg);
            }else{
                $scope.gates = data.data.data;
                $scope.pages.totalPages = data.data.count;
            }
        })
    };

    //闸机列表
    commonList($cookieStore.company_id,$scope.pages.currentPage,$scope.pages.pageSize);

    //切换分页
    $scope.changePages = function (page) {
        commonList($cookieStore.company_id,page,$scope.pages.pageSize)
    }

});